package SecondeStage.IO.Reader_Writer;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class BufferedWriter_ {
    public static void main(String[] args) throws IOException {
        String filePath ="D:\\Java\\JavaProject\\ok.txt";
        // new BufferedWriter(new FileWriter(filePath,true)) 表示以追加的方式写入
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(filePath,true));
        bufferedWriter.write("hello,韩顺平教育");
        bufferedWriter.newLine(); // 插入一个和系统相关的换行
        bufferedWriter.write("hello2,韩顺平教育");

        // 关闭流,这里只需要关闭外层流,因为底层会自动关闭节点流
        bufferedWriter.close();
    }
}
